package demo;

import java.util.Scanner;

public class test {
    public static void main(String[] args) {
        String username = "zhangsan";
        String password = "123456";
        for (int i = 0; i < 3; i++) {
            Scanner s = new Scanner(System.in);
            System.out.println("请输入用户名：");
            String name = s.nextLine();
            System.out.println("请输入密码：");
            String code = s.nextLine();

            // 判断
            if (name.equals(username) && code.equals(password)) {
                System.out.println("登录成功");
                break;
            } else if (i == 2){
                System.out.println("错误次数过多，您的账号已被锁定！");
            } else {
                System.out.println("账号或密码错误！");
            }
        }
    }
}
